<!DOCTYPE html>
<?php
include 'product.php';
sesion_start();
$sum = 0;
if(!empty($_SESSION['CART'])){
	$order = $_SESSION['CART'];
	$sum = array_sum(array_column($order,"num"))
}
?>
<html>
	<head>
		<meta charset="utf-8">
		<title>PHP购物</title>
	</head>
	<body>
		<div>
			<h1>商品列表</h1><hr />
			<table>
				<tr>
					<th>商品名</th>
					<th>售价</th>
					<th>购物车</th>
				</tr>
				<?php foreach ($products as $key => $value):?>
				<tr>
					<td><?php echo $value['name'];?></td><!--商品名-->
					<td>￥<?php echo $value['price'];?></td><!--商品价格-->
					<td><a class="btn" href=" =
					<?php echo $value['id'];?>
					$name=<?php echo $value['name'];?>
					$price=<?php echo $value['price'];?>">+</a></td>
				</tr>
				<?php endforeach;?>
			</table>
			<div>
				<a href="">我的购物车</a>
				<span><?php echo $sum;?></span>
			</div>
		</div>
	</body>
</html>
